Repository navigation
fix(typescript): lift the per-call budget cap, exit 124 on timeout, guard deep nesting - #2835
Conversation
…uard deep nesting - Each ts call reserved max_allocations (1M) work units, capping a script at about 95 calls. Charge 4096 units plus VM time instead. - ZapCode time limit now exits 124 with 'ts: execution timed out after Ns'. - ZapCode's parser/compiler recurse without a depth guard; ~6 KB of nested source aborted the host process. Add a conservative nesting estimate (cap 1000) and run parse/compile on a 128 MiB-stack thread (TM-TS-024).
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | d34291c | Commit Preview URL Branch Preview URL |
Nov 05 2026, 05:04 AM |
There was a problem hiding this comment.
Review of the TS timeout/budget/nesting fix. The core fixes look right (exit 124 keyed off TimeLimitExceeded, fixed 4096-unit admission charge instead of the 1M reservation, conservative nesting estimate before ZapCode). Findings below are about holes in the new stack-overflow mitigation.
Review summary — #2835
|
…hread - snapshot.resume after a VFS/external call now runs on the 128 MiB thread too. - No inline fallback when the thread cannot start: exit 1 with 'ts: cannot start execution thread'. - Port TM-TS-024 to the public threat model; document wasm residual risk.
Requested by Михайло · project thread
What changed
The TypeScript (ZapCode) runtime had the same gaps that a downstream review found in the Python runtime (#2831, #2832, #2833), plus one that crashes the host process:
[[[...]]]or1+1+..., overflowed the native stack and aborted the whole host (SIGABRT) in release builds. On a 2 MB debug thread it took only about 100 levels. Bashkit now guards this in two layers:typescript_nesting.rs) rejects source estimated deeper than 1000 levels withts: source is too deeply nested(exit 1).tscall reservedmax_allocations(1M) budget units up front, so a script hit the default 100M budget after about 95 calls. Each call is now charged a flat 4096 units plus the time the VM actually ran.ts: execution timed out after Ns, matchingpython3and coreutilstimeout. The exit code comes from ZapCode's dedicated error variant, so a script's ownthrowcannot fake it.Why
Agents run
tsmany times per script. A crafted few KB of source must never take down a multi-tenant host, and callers need to tell a limit hit apart from a script error.Before / After
ts -c 'let x = [[[…3000…]]]'(release)rc=1,ts: source is too deeply nested (estimated depth …, limit 1000)ts -c 'let x = 1'in one scriptwhile(true){}with a 200 ms limitrc=1,execution time limit exceededrc=124,ts: execution timed out after 0.2sTests:
deeply_nested_source_fails_cleanlydeep_nesting_at_the_limit_does_not_overflow(18 AST shapes at the deepest accepted size)deep_nesting_past_the_limit_is_rejectedmany_small_invocations_fit_in_one_scripttime_limit_exits_124thrown_error_is_not_a_limitRisk
,or;(for example, a giant string concatenation) is now rejected. Ordinary programs, long arrays and long statement lists score well under 100.tscall now spawns one thread, which costs tens of microseconds.Checklist
Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.